package com.example.uitls;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;

/**
 * Created by leonardo on 17/5/27.
 */

//1.Fucntion init(context) should be called in the class that extends Application

//2.we can call the mehtod getString/getDrawable and etc methods ,even if there is some changed ,we can quickly fix it.

public class ResUtils {
    private static ResUtils mInstance;
    private Context mContext;

    public ResUtils(Context mContext) {
        this.mContext = mContext;
    }

    public static void init(Context context) {
        mInstance = new ResUtils(context.getApplicationContext());
    }

    public static ResUtils getInstance() {
        return mInstance;
    }


    public String getString(@StringRes int id) {
        return mContext.getString(id);
    }

    public Drawable getDrawable(@DrawableRes int id) {
        return ContextCompat.getDrawable(mContext,id);
    }
}

